package top.lunarye.handler.utils;

import top.lunarye.common.domaim.TaskInfo;
import top.lunarye.common.enums.ChannelType;
import top.lunarye.common.enums.MessageType;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;

/**
 * groupId 工具类
 * @author lunar
 * @since 2022-07-18
 */
public class GroupIdMappingUtils {

    /**
     * 获取所有的groupIds
     * @return
     */
    public static List<String> getAllGroupIds() {
        var groupsIds = new ArrayList<String>();
        for (var channelType : ChannelType.values()) {
            for (var messageType : MessageType.values()) {
                groupsIds.add(channelType.getCodeEn() + "." + messageType.getCodeEn());
            }
        }
        return groupsIds;
    }

    public static String getGroupIdByTaskInfo(TaskInfo taskInfo) {
        var channelCodeEn = ChannelType.getEnumByCode(taskInfo.getSendChannel()).getCodeEn();
        var msgCodeEn = MessageType.getEnumByCode(taskInfo.getMsgType()).getCodeEn();
        return channelCodeEn + "." + msgCodeEn;
    }
}
